package com.lcj.demo.service;

import com.lcj.demo.domain.Job;
import com.lcj.demo.repository.JobRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class JobService {
    private final JobRepository jobRepository;
    public JobService(JobRepository jobRepository){
        this.jobRepository = jobRepository;
    }

    public Job saveOrUpdate(Job job){
        return jobRepository.save(job);
    }

    @Transactional(readOnly = true)
    public List<Job> findAll(){
        return jobRepository.findAll();
    }

    public  void  delete(Long id){
        jobRepository.deleteById(id);
    }

}
